package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.FavouredNorm;
import com.lrkj.payfee.service.IFavouredNormService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 优惠政策收费标准中间Controller
 *
 * @author yajun_ren
 * @date 2021-08-14
 */
@RestController
@RequestMapping("/payfee/favouredNorm")
public class FavouredNormController extends BaseController
{
    @Autowired
    private IFavouredNormService favouredNormService;

    /**
     * 查询优惠政策收费标准中间列表
     */
    @ApiOperation(value = "查询优惠政策收费标准中间列表", notes = "查询优惠政策收费标准中间列表")
    @GetMapping("/list")
    public TableDataInfo list(FavouredNorm favouredNorm)
    {
        startPage();
        List<FavouredNorm> list = favouredNormService.selectFavouredNormList(favouredNorm);
        return getDataTable(list);
    }

    /**
     * 导出优惠政策收费标准中间列表
     */
	@ApiOperation(value = "导出优惠政策收费标准中间列表", notes = "导出优惠政策收费标准中间列表")
    @PreAuthorize("@ss.hasPermi('payfee:favouredNorm:export')")
    @Log(title = "优惠政策收费标准中间", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FavouredNorm favouredNorm)
    {
        List<FavouredNorm> list = favouredNormService.selectFavouredNormList(favouredNorm);
        ExcelUtil<FavouredNorm> util = new ExcelUtil<FavouredNorm>(FavouredNorm.class);
        return util.exportExcel(list, "优惠政策收费标准中间数据");
    }

    /**
     * 获取优惠政策收费标准中间详细信息
     */
	@ApiOperation(value = "获取优惠政策收费标准中间详细信息", notes = "获取优惠政策收费标准中间详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:favouredNorm:query')")
    @GetMapping(value = "/{favouredPolicyId}")
    public AjaxResult getInfo(@PathVariable("favouredPolicyId") String favouredPolicyId)
    {
        return AjaxResult.success(favouredNormService.selectFavouredNormById(favouredPolicyId));
    }

    /**
     * 新增优惠政策收费标准中间
     */
	  @ApiOperation(value = "新增优惠政策收费标准中间", notes = "新增优惠政策收费标准中间")
    @PreAuthorize("@ss.hasPermi('payfee:favouredNorm:add')")
    @Log(title = "优惠政策收费标准中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FavouredNorm favouredNorm)
    {
        return toAjax(favouredNormService.insertFavouredNorm(favouredNorm));
    }

    /**
     * 修改优惠政策收费标准中间
     */
	 @ApiOperation(value = "修改优惠政策收费标准中间", notes = "修改优惠政策收费标准中间")
    @PreAuthorize("@ss.hasPermi('payfee:favouredNorm:edit')")
    @Log(title = "优惠政策收费标准中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FavouredNorm favouredNorm)
    {
        return toAjax(favouredNormService.updateFavouredNorm(favouredNorm));
    }

    /**
     * 删除优惠政策收费标准中间
     */
	 @ApiOperation(value = "删除优惠政策收费标准中间", notes = "删除优惠政策收费标准中间")
    @PreAuthorize("@ss.hasPermi('payfee:favouredNorm:remove')")
    @Log(title = "优惠政策收费标准中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{favouredPolicyIds}")
    public AjaxResult remove(@PathVariable String[] favouredPolicyIds)
    {
        return toAjax(favouredNormService.deleteFavouredNormByIds(favouredPolicyIds));
    }
}
